package org.mtmi.ui.scenes;

import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Shell;
import org.mtmi.ui.IMG;
import org.mtmi.ui.M;
import org.mtmi.ui.controls.AbstractKnob;
import org.mtmi.ui.controls.Control;
import org.mtmi.ui.controls.Knob;
import org.mtmi.ui.controls.SButton;
import org.mtmi.ui.controls.SKnob;
import org.mtmi.ui.controls.SSlider;
import org.mtmi.ui.layouts.GridData;
import org.mtmi.ui.layouts.GridLayout;
import org.mtmi.ui.layouts.LayoutData;

/**
 * A Scene to test controls using image as skin.
 */
public class BeurkScene extends Scene {

	public BeurkScene(Shell parent) {
		super(parent);
		Rectangle ca = parent.getClientArea();
		setSize(ca.width, ca.height);
		init();
	}
	
	private void init() {
		
		String k1b = "tests/knob1_back.png";
		String k1k = "tests/knob1_center.png";
		
		String k2b = "tests/knob2_back.png";
		String k2k = "tests/knob2_center.png";
		
		String t1b = "tests/slider1_back.png";
		String t1t = "tests/slider1_thumb.png";
		
	/*	Control b1[] = new Control[8];
		for( int i=0; i<b1.length; i++ ) {
			switch( i%3 ) {
			case 0: b1[i] = new SButton( this, en1, ar1, M.SCENE_CONTROL ); break;
			case 1: b1[i] = new SKnob( scene1, k1b,k1k, M.SCENE_CONTROL ); break;
			case 2: b1[i] = new SSlider( scene1, false, t1b,t1t, 0,100, M.SCENE_CONTROL ); break;
			}
		}
		int cols=5*/
		
		int N=7;
		Control b1[] = new Control[5*N];
		for( int i=0; i<N; i++ ) {
			String b,k;
			if( (i%2)==0 ) {
				b=k1b; k=k1k;
			} else {
				b=k2b; k=k2k;
			}
			b1[i] = new SKnob( this, b,k, M.SCENE_CONTROL );
			b1[i].setData( M.D_LAYOUT_DATA, new GridData(M.CENTER,false,M.CENTER,false,2) );
		}
		for( int i=0; i<4*N; i++ ) {
			b1[N+i] = new SSlider( this, t1b,t1t, 0,0,100, M.VERTICAL|M.SCENE_CONTROL );
		}
		int cols=2*N;
		
		GridLayout gl = new GridLayout(cols,false);
		//gl.setMargins( 10 );
		//gl.setSpacings( 10 );
		GC gc = new GC( this );
		try {
			LayoutData ld = new LayoutData( gc, 0,0, getSize().x, getSize().y );
			gl.layout( ld, b1 );
		} finally {
			gc.dispose();
		}
		
		/*TODO: test image and painted knob:
		SKnob k = new SKnob( this, k1b,k1k, M.SCENE_CONTROL );
		Knob k2 = new Knob( this, M.SCENE_CONTROL );
		k2.setLocation( 200, 50 );*/
	}
	
}
